//
//  KATBanner.h
//  KATFramework
//
//  Created by Kantice on 15/9/11.
//  Copyright (c) 2015年 KatApp. All rights reserved.
//  幻灯片轮播控件
//  为避免循环引用，幻灯片从父视图中移除时，会自动关闭获取网络图片和自动轮播的定时器，若要再次添加到新的视图，需要reloadData


#import <UIKit/UIKit.h>

#import "KATBannerData.h"
#import "KATArray.h"
#import "KATColor.h"
#import "KATBannerDelegate.h"
#import "KATSprite.h"
#import "KATImage.h"



#define BANNER_CHANGE_MODE_NONE 0
#define BANNER_CHANGE_MODE_LEFT 1
#define BANNER_CHANGE_MODE_RIGHT 2

#define BANNER_STATE_READY 0
#define BANNER_STATE_PAN 1
#define BANNER_STATE_CHANGE 2
#define BANNER_STATE_RELOAD 3
#define BANNER_STATE_INIT 9


#define BANNER_CHANGE_MIDDLE 0
#define BANNER_CHANGE_LEFT 1
#define BANNER_CHANGE_RIGHT 2



@interface KATBanner : KATSprite
{
    double _lastScale;//上次缩放比例
    
    BOOL _isTaped;//双击检测
}


#pragma -mark 属性

///状态
@property(nonatomic,assign) int state;

///切换模式
@property(nonatomic,assign) int changeMode;

///是否停止自动切换
@property(nonatomic,assign) BOOL stoped;

///是否为自动切换轮播模式（左滑后改为左轮播）
@property(nonatomic,assign) BOOL isAutoChangeMode;

///是否可以缩放(缩放和轮播冲突，设置了缩放模式，则停止轮播)
@property(nonatomic,assign) BOOL scalable;

///是否为循环模式
@property(nonatomic,assign) BOOL isCycleMode;

///是否已经缩放
@property(nonatomic,assign,readonly) BOOL scaled;

///缩放比例
@property(nonatomic,assign,readonly) float scale;

///最大缩放比例
@property(nonatomic,assign) float scaleMax;

///默认最大缩放比例(若实际图片尺寸未超过该比例尺寸)
@property(nonatomic,assign) float scaleMaxDefault;

///动画时间
@property(nonatomic,assign) float animateTime;

///双击检测时间
@property(nonatomic,assign) float doubleClickCheckTime;

///是否快速拖动图片
@property(nonatomic,assign,readonly) BOOL isQuicklyPan;

///快速滑动方向
@property(nonatomic,assign,readonly) int quicklyPanDirection;

///容器
@property(nonatomic,retain,readonly) UIView *container;

///左图
@property(nonatomic,retain,readonly) KATImage *leftImage;

///中图（显示的图片）
@property(nonatomic,retain,readonly) KATImage *middleImage;

///右图
@property(nonatomic,retain,readonly) KATImage *rightImage;

///左图索引
@property(nonatomic,assign,readonly) int leftImageIndex;

///中图索引
@property(nonatomic,assign,readonly) int middleImageIndex;

///右图索引
@property(nonatomic,assign,readonly) int rightImageIndex;

///是否包含缓冲图
@property(nonatomic,assign) BOOL hasCacheImage;

///缓冲图
@property(nonatomic,retain) UIImage *cacheImage;

///图片间距
@property(nonatomic,assign) float padding;

///数据数组
@property(nonatomic,retain,readonly) KATArray<__kindof KATBannerData *> *dataArray;

///指示器数组
@property(nonatomic,retain,readonly) KATArray<__kindof KATButton *> *indicatorArray;

///事件代理
@property(nonatomic,assign) id<KATBannerDelegate> eventDelegate;

///标题控件
@property(nonatomic,retain) UILabel *title;

///是否显示标题
@property(nonatomic,assign) BOOL hasTitle;

///标题frame
@property(nonatomic,assign) CGRect titleFrame;

///标题颜色
@property(nonatomic,retain) UIColor *titleColor;

///标题背景颜色
@property(nonatomic,retain) UIColor *titleBgColor;

///标题字体
@property(nonatomic,retain) UIFont *titleFont;

///标题对齐方式
@property(nonatomic,assign) NSTextAlignment titleAlignment;

///标题显示行数
@property(nonatomic,assign) int titleLines;

///标题换行模式
@property(nonatomic,assign) NSLineBreakMode titleLineBreak;


///前景条
@property(nonatomic,retain,readonly) UIView *frontBar;

///是否包含前景条
@property(nonatomic,assign) BOOL hasFrontBar;

///前景条frame
@property(nonatomic,assign) CGRect frontBarFrame;

///前景条颜色
@property(nonatomic,retain) UIColor *frontBarColor;


///指示器高度
@property(nonatomic,assign) float indicatorHeight;

///指示器间距
@property(nonatomic,assign) float indicatorPaddingInner;

///指示器下边距
@property(nonatomic,assign) float indicatorPaddingBottom;

///指示器颜色
@property(nonatomic,retain) UIColor *indicatorColor;

///指示器高亮时候的透明度
@property(nonatomic,assign) float indicatorLightAlpha;

///指示器暗淡时候的透明度
@property(nonatomic,assign) float indicatorDarkAlpha;

///指示器线宽
@property(nonatomic,assign) float indicatorLineWidth;


///是否有远程图片
@property(nonatomic,assign) BOOL hasRemoteImage;

///远程图片更新定时器
@property(nonatomic,retain,readonly) NSTimer *remoteImageUpdateTimer;

///远程图片更新定时器是否在工作
@property(nonatomic,assign) BOOL isRemoteImageUpdateTimerWorking;

///远程图片更新时间间隔
@property(nonatomic,assign) double remoteImageUpdateInterval;


///图片轮播定时器
@property(nonatomic,retain,readonly) NSTimer *changeImageTimer;

///图片轮播定时器是否在工作
@property(nonatomic,assign) BOOL isChangeImageTimerWorking;

///图片轮播时间间隔
@property(nonatomic,assign) double changeImageInterval;


#pragma -mark 类方法

///获取实例
+ (instancetype)bannerWithFrame:(CGRect)frame;


#pragma -mark 对象方法

///重新加载数据
- (void)reloadData:(KATArray<__kindof KATBannerData *> *)dataArray;

///获取当前的数据
- (KATBannerData *)currentData;

///直接改变显示的数据（不会触发改变图片事件）
- (void)changeWithData:(KATBannerData *)data;


///释放内存
- (void)dealloc;


@end



